package com.sx.manage.controller.file;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sx.common.util.StringUtil;
import com.sx.manage.controller.base.MBaseController;

/** 文件下载controller**/
@Controller
@RequestMapping("/download")
public class MFileDownLoadController extends MBaseController {
	/**
	 * 日志
	 */
	private Logger log = LoggerFactory.getLogger(this.getClass());
	/**文件下载*/
	@ResponseBody
	@RequestMapping(value = "/fileDownload/{pathName}/{filename}", produces = "application/json; charset=utf-8")
	public boolean wageDownload(@PathVariable String pathName, @PathVariable String filename) {
		log.info("pathName:{}, filename:{}", pathName, filename);
		if (StringUtil.isBlank(filename) || StringUtil.isBlank(pathName)) {
			log.info("文件下载失败，路径或文件名称为空");
			return false;
		}
//		String urlStr = OSSUtils.getFileUrl(filename, pathName);
//		log.info("{}重定向路径为：{}", pathName, urlStr);
//		try {
//			response.sendRedirect(urlStr);
//		} catch (IOException e) {
//			log.error("下载跳转重定向失败：{}", e);
//		}
		return true;
	}
}
